package com.cloudsigns.factorymanager2.engineering.presenter;

import com.cloudsigns.factorymanager2.engineering.IView.IPatrolOrderAssignReceiveDetailView;
import com.cloudsigns.factorymanager2.engineering.bean.PatrolOrderBean;
import com.cloudsigns.factorymanager2.engineering.model.IPatrolOrderAssignReceiveDetailModel;
import com.cloudsigns.factorymanager2.engineering.model.PatrolOrderAssignReceiveDetailModel;

/**
 * Created by tony on 2018/5/17.
 */

public class PatrolOrderAssignReceiveDetailPresenter {
    private IPatrolOrderAssignReceiveDetailView view;
    private IPatrolOrderAssignReceiveDetailModel model;
    private android.os.Handler mHandler = new android.os.Handler();

    public PatrolOrderAssignReceiveDetailPresenter(IPatrolOrderAssignReceiveDetailView view) {
        this.view = view;
        this.model = new PatrolOrderAssignReceiveDetailModel();
    }

    public void getPatrolOrderAssignReceiveDetail() {


        model.getPatrolOrderAssignReceiveDetail(view.getOrderId(),
                new PatrolOrderAssignReceiveDetailModel.OnPatrolOrderAssignReceiveDetailListener() {
                    @Override
                    public void getPatrolOrderAssignReceiveDetailSuccessed(final PatrolOrderBean patrolOrderBean) {
                        //需要在UI线程执行
                        mHandler.post(new Runnable() {
                            @Override
                            public void run() {
                                view.getPatrolOrderAssignReceiveDetailSuccessed(patrolOrderBean);
                                view.hideLoading();
                            }
                        });
                    }

                    @Override
                    public void getPatrolOrderAssignReceiveDetailFailed(final String desc) {
                        //需要在UI线程执行
                        mHandler.post(new Runnable() {
                            @Override
                            public void run() {
                                view.getPatrolOrderAssignReceiveDetailFailed(desc);
                                view.hideLoading();
                            }
                        });
                    }
                });

    }
}
